<div class="onecolumn" >
	<div class="header"> <span ><span class="ico gray notepad"></span><?php echo Yii::app()->name;?> - Media</span> 
	<span style="float:right; margin:-3px 25px 0 0;"><a href="<?php echo Yii::app()->getBaseUrl()?>/admin/media/add" class="uibutton">Add Image</a></span>
	</div>
    <div class="clear"></div>
<div class="content" >

<div class="wide form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'action'=>Yii::app()->createUrl($this->route),
	'method'=>'get',
)); ?>

	<div class="section">
		<label><?php echo $form->label($model,'type'); ?></label>
		<div><?php echo $form->dropdownList($model,'type',array('1'=>'Image', '2'=>'PDF'),array('class'=>'large')); ?></div>
	</div>
	
	<div class="section">
		<label><?php echo $form->label($model,'name'); ?></label>
		<div><?php echo $form->textField($model,'name',array('class'=>'large')); ?></div>
	</div>

	<div class="section buttons">
	<label>&nbsp;</label>
		<div><?php echo CHtml::submitButton('Search', array('class'=>'uibutton')); ?></div>
	</div>

<?php $this->endWidget(); ?>

</div><!-- search-form -->


<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl?>/admin_assets/js/checkboxes_operation.js"></script>
<script>
$(document).ready(function(){
	$('table.dataTable').prop('id','user_table');
	$('#contact_all').addClass('checkAll');
	$('.checkAll,.chkbox').customInput();
});
</script>

<form action="<?php echo Yii::app()->getBaseUrl()?>/admin/media/process" method="post" id="contact" name="contact">
<input type="hidden" name="pageAction" id="pageAction" />
<?php 
$this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'userTable',
	'dataProvider'=>$model->search(),
	'enableSorting'=>'true',
	'summaryText'=>'',
	'ajaxUpdate'=>false,
	'itemsCssClass'=>'sortTable display dataTable',
	'pager'=>array(
			'header'=>false,
			'firstPageLabel' => 'First',
			'prevPageLabel' => 'Previous',
			'nextPageLabel' => 'Next',
			'lastPageLabel' => 'Last',
			),
	'columns'=>array(
			array(
					'name' =>'contact[]',
					'class'=>'CCheckBoxColumn',
					'selectableRows'=>2,
					'id'=>'contact',
					'value'=>'$data->id',
					'checkBoxHtmlOptions'=>array('class'=>'chkbox'),
			),
			array(
					'name' => 'name',
					'value' => '!empty($data->name)?$data->name:"N/A"',
			),
			array(
					'name' => 'url',
					'value' => 'CHtml::link($data->url,$data->type == 1 ? Yii::app()->getBaseUrl()."/images/".$data->url :Yii::app()->getBaseUrl()."/pdf/".$data->url, array("target"=>"_blank"))',
					'type' => "raw"
			),
			array(
					'name'=>'image',
					'type' => 'raw',
              		'value' => '$data->type == 1 ? CHtml::image(Yii::app()->getBaseUrl()."/images/".$data->url, "FILE" ,array("width"=>100)) : CHtml::image(Yii::app()->getBaseUrl()."/images/pdf-icon.png", "FILE" ,array("width"=>100))'
			),
			
			array( // display a column with "view", "update" and "delete" buttons
					'class'=>'CButtonColumn',
					'template'=>'{Delete}',
					'buttons'=>array
					(
						'Delete' => array
						(
								'imageUrl'=>Yii::app()->request->baseUrl.'/admin_assets/images/icon/color_18/close.png',
								'url'=>'Yii::app()->createUrl("admin/media/delete", array("id"=>$data->id,"name"=>$data->url))',
								'options'=>array('name'=>'Image', 'class'=>'Delete_contact'),
						),
					),
			),
		),
)); 
?>
<a class="uibutton special" id="Delete_user" name="delete" onclick="validateChk('contact', 'delete');">Delete</a>
</form>
</div></div>
<style type="text/css">
.button-column a img{
		width:164x;
		height:14px;
		margin:2px;
}
td, th{
	text-align:left;
}
</style>
<script type="text/javascript">

</script>
